Skip to content

ci: complete maintenance workflow authorization - #24696

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
qiancai:fix-maintenance-workflow-authorization
Nov 16, 2026
Merged

ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
qiancai:fix-maintenance-workflow-authorization

Conversation

@qiancai

@qiancai qiancai commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What is changed, added, or deleted? (Required)

Require authorization before maintenance workflows can scan links, create link-report issues, or use translation credentials.

  • Port the shared authorization gate from docs-cn, adjusted for pingcap/docs. It checks the repository and master branch, verifies the existing three allowed accounts by immutable account ID and current write/maintain/admin permission, and validates rerun initiators. Initial scheduled runs remain supported.
  • Gate the link-check and Chinese-to-English PR sync jobs on authorization for the current run attempt, so partial reruns cannot reuse an earlier authorization.
  • Restrict the keywords workflow to master in addition to its existing repository check.
  • Add authorization regression tests and run them in existing CI. Tests cover allowed and rejected dispatches, forks, non-master branches and tags, revoked permissions, scheduled runs, and reruns.

The English repository has no flush-version.yaml; its corresponding PR synchronization workflow is sync-doc-pr-zh-to-en.yml.

Validation: authorization, media, doc-review, and safer-default regression scripts passed; actionlint -shellcheck= passed for all changed workflows; git diff --check passed. No production workflows were manually dispatched and no production secrets were used.

Scope: these guards restrict execution of the reviewed workflows. They do not isolate repository-level secrets from branch writers who can edit workflow definitions; separate repository/environment secret controls are required for that threat model.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • Workflow Updates
    • Privileged documentation workflows now verify the repository, branch, event, account permissions, and rerun initiator before running.
    • Keyword checks now run only for the documentation repository’s master branch.
    • Privileged tasks proceed only when authorization succeeds, including during partial reruns.

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds a reusable GitHub Actions workflow that authorizes privileged runs. The link checker and documentation sync use its authorization output to gate execution. The keyword job now runs only on the upstream master ref. A new test suite checks authorization behavior and workflow wiring.

Changes: Privileged workflow authorization

Layer / File(s) Summary
Shared authorization checks
.github/workflows/authorize-privileged-workflow.yml
The reusable workflow checks the repository and ref, applies event-specific actor and permission checks, validates rerun initiators, and outputs the authorized run attempt.
Privileged workflow gates
.github/workflows/link.yaml, .github/workflows/sync-doc-pr-zh-to-en.yml, .github/workflows/keywords.yaml
The link checker and documentation sync require a matching authorization attempt. The keyword job requires the pingcap/docs repository and refs/heads/master.
Authorization tests and CI wiring
scripts/test-privileged-workflow-actors.py, .github/workflows/ci.yaml
The new tests cover authorization cases, workflow wiring, and CI permissions. CI runs the test suite.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant CallerWorkflow
  participant AuthorizePrivilegedWorkflow
  participant GitHubAPI
  participant PrivilegedJob
  CallerWorkflow->>AuthorizePrivilegedWorkflow: Invoke reusable authorization workflow
  AuthorizePrivilegedWorkflow->>GitHubAPI: Check collaborator permission and account ID
  GitHubAPI-->>AuthorizePrivilegedWorkflow: Return account identity and permission
  AuthorizePrivilegedWorkflow-->>CallerWorkflow: Return authorized run attempt
  CallerWorkflow->>PrivilegedJob: Run when authorized attempt matches current attempt
Loading

Possibly related PRs

  • pingcap/docs#24677: Both changes define actor allowlists for privileged runs of the documentation sync workflow.

Suggested reviewers: lilin90, shhdgit, alastori

Merge Risk: Minimal · up to e6170

This change requires authorization before the link-check and Chinese-to-English sync workflows run, and it limits the keyword scan to master. I found no merge-blocking risk. Repository-level secrets still need separate controls against branch writers who can edit workflow definitions, as the PR states.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "ci: complete maintenance workflow authorization" matches the main change: a shared authorization gate for maintenance workflows, with link-check and zh-to-en sync jobs gated on it. It is sh…
Description check Passed The description follows the template. It includes the required 'What is changed' section with a clear explanation, the version checkbox (master ticked), related PR links, and the AI agent involvement …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "ci: complete maintenance workflow authorization" matches the main change: a shared authorization gate for maintenance workflows, with link-check and zh-to-en sync jobs gated on it. It is short, specific, and follows a conventional prefix. It omits the keywords restriction and the tests, which is acceptable.

Full details: Description check

Explanation

The description follows the template. It includes the required 'What is changed' section with a clear explanation, the version checkbox (master ticked), related PR links, and the AI agent involvement checkbox. It also reports validation steps and scope limits. The template's first-time contributor checklist and the 'Do your changes match' list are left unticked, which is acceptable for a non-required or non-applicable item. The 'Which TiDB version(s)' section and 'related PR' section are both filled in.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: pingcap/docs
  • Branch: master
  • File: .coderabbit.yaml
  • Commit: d0f1fb1
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e6e64081-7fdb-4a9d-992c-0314f2a9163d
Commits

Reviewing files that changed from the base of the PR and between d0f1fb1 and e617062.

Files selected for processing: 6

  • .github/workflows/authorize-privileged-workflow.yml
  • .github/workflows/ci.yaml
  • .github/workflows/keywords.yaml
  • .github/workflows/link.yaml
  • .github/workflows/sync-doc-pr-zh-to-en.yml
  • scripts/test-privileged-workflow-actors.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@qiancai qiancai added translation/no-need No need to translate this PR. and removed missing-translation-status This PR does not have translation status info. labels Nov 16, 2026
@lilin90
lilin90 requested a balanced review from Copilot November 16, 2026 07:55
@lilin90 lilin90 added the ONCALL Relates to documentation oncall. label Nov 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain in the privileged-workflow authorization changes.

No open issues 🎉

What changed in this PR

This PR adds shared authorization checks to privileged maintenance workflows in pingcap/docs, covering link checks and Chinese-to-English PR synchronization.

Changes:

  • Validate the repository, master branch, allowed account IDs, current permissions, and rerun initiators while preserving initial scheduled runs.
  • Require authorization for the current run attempt and restrict keyword checks to upstream master.
  • Add authorization regression tests to existing CI.
File Description
scripts/​test-privileged-workflow-actors.py Adds regression tests for authorization and workflow gates.
.github/​workflows/​sync-doc-pr-zh-to-en.yml Requires current-attempt authorization before PR synchronization.
.github/​workflows/​link.yaml Requires current-attempt authorization before link checks.
.github/​workflows/​keywords.yaml Restricts keyword checks to upstream master.
.github/​workflows/​ci.yaml Runs the new authorization regression tests.
.github/​workflows/​authorize-privileged-workflow.yml Defines the reusable authorization gate.

Review effort: Balanced

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-11-16 08:05:21.893310926 +0000 UTC m=+1690646.518461201: ☑️ agreed by lilin90.

@qiancai

qiancai commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

/approve

@qiancai qiancai added the lgtm label Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiancai

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Nov 16, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 47da5e8 into pingcap:master Nov 16, 2026
12 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 16, 2026
3 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. ONCALL Relates to documentation oncall. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants